home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 9536 / 9536.xpi / chrome / commentsbar_ff.jar / content / commentsbar_ff / postinst.js < prev    next >
Text File  |  2009-03-25  |  4KB  |  161 lines

  1. var type="1";
  2. var src="chrome://commentsbar_ff/content/fr.xul";
  3. var windframe;
  4. var mainwindow;
  5. var name;
  6. var tool;
  7. var isDragged = false;
  8. var searchchbox;
  9. var homechbox;
  10.  
  11. window.onload = function () {
  12. try{
  13. window.sizeToContent ();
  14.  
  15. var wind = document.getElementById('postinst');
  16. var x=toolbar_load_pref(name + "_screenx" ,"");
  17. var y=toolbar_load_pref(name + "_screeny" ,"");
  18.  
  19. var width=toolbar_load_pref(name + "_width" ,"");
  20. var height=toolbar_load_pref(name + "_height" ,"");
  21. type=toolbar_load_pref(name + "_type" ,"");
  22. var scroll=toolbar_load_pref(name + "_scroll" ,"");
  23.  
  24. wind.setAttribute('screenX',x);
  25. wind.setAttribute('screenY',y);
  26. wind.setAttribute('width',width);
  27. wind.setAttribute('height',height);
  28.  
  29. windframe = document.getElementById('postinstframe');
  30. windframe.setAttribute('src',src);
  31. windframe.setAttribute('height',height);
  32.  
  33. //alert("@@@");
  34. if (scroll=="0") windframe.setAttribute('style',"border: 0px solid ; margin: 0px;padding: 0px;");
  35.  
  36. if (windframe.contentWindow.DocumentComplete) windframe.contentWindow.DocumentComplete(tool);
  37.  
  38. if (windframe.contentWindow.ToolBarInit) windframe.contentWindow.ToolBarInit(tool);
  39.  
  40. windframe.addEventListener("load", loadframe, true);
  41.  
  42. }catch(e){alert(e);}
  43. }
  44.  
  45. function startdelay ()
  46. {
  47. src=windframe.contentDocument.location;
  48. if (type=="0") delay();
  49. }
  50.  
  51. function delay ()
  52. {
  53. try{
  54.  
  55. var href=windframe.contentDocument.location;
  56. var temp=''+href;
  57. var offset=0;
  58. offset=temp.indexOf('inbanner',0);
  59.     if (href==src ||  offset != -1)
  60.         {
  61.         setTimeout ('delay();', 10);
  62.         return;
  63.     }
  64. //toolbar_pref( "newlocation", windframe.contentDocument.location );
  65. mainwindow._content.document.location=windframe.contentDocument.location;
  66. //alert(windframe.contentDocument.location);
  67. window.close();
  68. }catch(e){alert(e);}
  69. }
  70.  
  71.  
  72. function loadframe()
  73. {
  74. try{
  75. if (windframe.contentWindow.DocumentComplete) windframe.contentWindow.DocumentComplete(tool);
  76. if (windframe.contentWindow.ToolBarInit) windframe.contentWindow.ToolBarInit(tool);
  77. setTimeout(startdelay,1000);
  78. }catch(e){alert(e);}
  79. }
  80.  
  81.  
  82. function toolbar_getPrefBranch()
  83. {
  84. try {
  85.     var prefService = Components.classes["@mozilla.org/preferences-service;1"]
  86.                         .getService(Components.interfaces.nsIPrefService);
  87.     return prefService.getBranch(null);
  88. } catch(e) {alert(e);}
  89. }
  90.  
  91. function toolbar_pref(prefName, value)
  92. {
  93. try {
  94.     value=escape(value);
  95.     var prefBranch = toolbar_getPrefBranch();
  96.     if (typeof(value) == "number")
  97.         prefBranch.setIntPref(prefName, value);
  98.     else if (typeof value == "string")
  99.         prefBranch.setCharPref(prefName, value);
  100.     else if (typeof value == "boolean")
  101.         prefBranch.setBoolPref(prefName, value);
  102. } catch(e) {alert(e);}
  103. }
  104.  
  105. function toolbar_defaultPref(prefName, value)
  106. {
  107. try {
  108.     value=escape(value);
  109.     var prefService = Components.classes["@mozilla.org/preferences-service;1"]
  110.                         .getService(Components.interfaces.nsIPrefService);
  111.     var prefBranch = prefService.getDefaultBranch(null);
  112.     if (typeof value == "string")
  113.         prefBranch.setCharPref(prefName, value);
  114.     else if (typeof value == "number")
  115.         prefBranch.setIntPref(prefName, value);
  116.     else if (typeof value == "boolean")
  117.         prefBranch.setBoolPref(prefName, value);
  118. } catch(e) {alert(e);}
  119. }
  120.  
  121. function toolbar_getPref(prefName)
  122. {
  123. try {
  124.     var prefBranch = toolbar_getPrefBranch();
  125.     switch (prefBranch.getPrefType(prefName))
  126.     {
  127.         case prefBranch.PREF_STRING:
  128.             return unescape(prefBranch.getCharPref(prefName));
  129.         case prefBranch.PREF_INT:
  130.             return prefBranch.getIntPref(prefName);
  131.         case prefBranch.PREF_BOOL:
  132.             return prefBranch.getBoolPref(prefName);
  133.         default:
  134.             return null;
  135.     }
  136. } catch(e) {alert(e);}
  137.     return null;
  138. }
  139.  
  140. function toolbar_clearPref(prefName)
  141. {
  142. try {
  143.     var prefBranch = toolbar_getPrefBranch();
  144.     toolbar_prefBranch.clearUserPref(prefName);
  145. } catch(e) {alert(e);}
  146. }
  147.  
  148. function toolbar_load_pref(pName, defValue)
  149. {
  150. try {
  151.     var val = toolbar_getPref(pName);
  152.     if( val == null )
  153.     {
  154.         val = defValue;
  155.         toolbar_defaultPref(pName, val);
  156.     }
  157.     return val;
  158. } catch(e) {alert(e);}
  159. }
  160.  
  161.